package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.dto.SetmealPageDTO;
import com.sky.entity.Setmeal;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface SetmealMapper {
    @Select("select count(*) from dish where category_id=#{id}")
    Integer findByCategoryId(Long id);
    @AutoFill("update")
    @Update("update setmeal set status=#{status} where id =(select setmeal_id from setmeal_dish where dish_id =#{id} )")
    void updateStatus(@Param("id") Long id,@Param("status") Integer status);
    @Select("select * from setmeal where name=#{name}")
    Setmeal findByName(String name);
    @AutoFill("insert")
    void save(Setmeal setmeal);

    List<SetmealVO> findList(SetmealPageDTO dto);
    @Select("select * from setmeal where id=#{id}")
    Setmeal findById(Long id);
    @AutoFill("update")
    void update(Setmeal setmeal);


    Integer findByIds(@Param("ids") Long[] ids);

    void deleteByIds(Long[] ids);

    void updateStatusByDish(@Param("id") Long id,@Param("status") Integer status,@Param("updateTime") LocalDateTime updateTime,@Param("updateUser") Long updateUser);
    @Select("select count(*) from setmeal where status=#{status}")
    Integer countStatus(Integer disable);
}
